package com.itheima.gateway.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @program: spring-cloud-parent
 * @description:
 * @author: zhanghz001
 * @create: 2021-02-03 20:23
 **/
@Component

public class MyGlobalFilter implements GlobalFilter, Ordered {
    /**
     * 过滤器排序
     *
     * @return 数值越小 越先执行
     */
    @Override
    public int getOrder() {
        return 0;
    }
    
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("过了全局过滤器了");
        return chain.filter(exchange);
    }
}
